﻿package ygg.encoding.swf
{
	import j.sus2maj7.encoding.*;
	import j.sus2maj7.context.*;
	
	import flash.utils.ByteArray;
	
	import ygg.encoding.swf.tag.*;
	
	public class SwfEncoding extends AbstractEncoding
	{
		
		public function SwfEncoding()
		{
			
		}
		
		public function get header():SwfHeader
		{
			return Swf(this.object).header;
		}
		
		public function get tags():Vector.<TagEncoding>
		{
			return Swf(this.object).tags;
		}
		
		
		override public function toString():String
		{
			return "Swf: \n" + Swf(this.object).header.toString() ;
		}
		
		override public function setBytes(ba:ByteArray):void
		{
			this.binary = new SwfBinary(ba);
			
		}
		
		override public function decode(context:IContext=null):void
		{
			if (!codec) codec =  new SwfCodec();
			this.object = codec.decode(binary);
			
			//_header = Swf(this.object).header;
			//_tags = Swf(this.object).tags;
			trace('SwfEncoding Decode Finished');
		}
		
		override public function encode(context:IContext=null):void
		{
			/*
			if (!codec) codec =  new SwfCodec();
			//*
			var ao:Swf = new Swf();
			ao.header = _header;// new SwfHeader('dfgdfg', 3, 0);
			ao.tags = _tags;
			
			binary = codec.encode(ao);
			//*/
		}
		/*
		public function addObject(key:String, value:*):void
		{
			_tags[key] = value;
		}*/
	}
}